﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace server.DataBase
{
    class ForumTree
    {

        public ForumTree()
        {
        }

        public Node<string> subforums = null;

        public void insertSubForum(string str)
        {
            subforums.brother.Add(new Node<string>(str));
        }
        public void insertThread(string str,int subNum)
        {
            subforums.brother.ElementAt(subNum).child.brother.Add(new Node<string>(str));
        }
        public void insertPost(string str, int subNum,int thrNum)
        {
            subforums.brother.ElementAt(subNum).child.brother.ElementAt(thrNum).brother.Add(new Node<string>(str));
        }
        /*
         * @param num - the number of sub forum to be shown
         */
        public string getXSubforums(int num,int page)
        {
            string result ="";
            for(int i=0;i<num;i++)
            {
                result += subforums.brother.ElementAt(i + page * num);
                result += '\n';
            }
            return result;
        }
        /*
         * @param num - the number of Threads to be shown
         */
        public string getXThreads(int num, int page,int subNum)
        {
            string result = "";
            for (int i = 0; i < num; i++)
            {
                result += subforums.brother.ElementAt(subNum).brother.ElementAt(i + page * num);
                result += '\n';
            }
            return result;
        }
        /*
         * @param num - the number of Threads to be shown
         */
        public string getXPosts(int num, int page, int subNum,int thrNum)
        {
            string result = "";
            for (int i = 0; i < num; i++)
            {
                result += subforums.brother.ElementAt(subNum).brother.ElementAt(thrNum).brother.ElementAt(i + page * num);
                result += '\n';
            }
            return result;
        }
    }






}
